package service.impl;

import pojo.Label;
import pojo.NoteLabels;
import service.LabelService;
import service.NoteLabelArrayService;
import service.NoteLabelsService;

import java.sql.SQLException;
import java.util.ArrayList;

public class NoteLabelArrayServiceImpl implements NoteLabelArrayService {

    public ArrayList<Label> labelArrayList(Integer nid) throws SQLException, ClassNotFoundException {
        ArrayList<Label> labels = new ArrayList<>();
        NoteLabelsService noteLabelsService = new NoteLabelsServiceImpl();
        LabelService labelService = new LabelServiceImpl();
        ArrayList<NoteLabels> labelArrayList = noteLabelsService.noteLabelsList(nid);
        for (NoteLabels noteLabels : labelArrayList) {
            Label label = new Label();
            label.setLabel(labelService.findLabelById(noteLabels.getLid()));
            label.setId(noteLabels.getLid());
            labels.add(label);
        }
        return labels;
    }
}
